package ai4games_tests.tests;

import game2dai.World;
import game2dai.entities.Building;
import game2dai.entityshapes.ps.BuildingPic;
import game2dai.maths.Vector2D;
import processing.core.PApplet;

public class ExpandedBuilding extends PApplet {
	World world;
	Building b;
	BuildingPic bpic;
	Vector2D[] c, ec;

	public void setup(){
		size(200,200);
		world = new World(width, height);
		c = new Vector2D[] { new Vector2D(50,50), new Vector2D(60,100), new Vector2D(50,150), new Vector2D(150,100) };

		bpic = new BuildingPic(this, color(200,200,255), color(0), 2);
		b = new Building(c);
		b.renderer(bpic);
		
		ec = b.expandedContour(20);
		
		world.add(b);
	}

	
	public void draw(){
		background(255);
		world.draw();
		stroke(255,0,0);
		strokeWeight(1);
		noFill();
		for(int i = 0; i < ec.length; i++){
			Vector2D np = ec[(i+1)%ec.length];
			line((float) ec[i].x, (float) ec[i].y, (float)np.x, (float)np.y);
		}
	}
}
